<%@ page import="org.apache.commons.codec.binary.Base64" %>
<%--
  Created by IntelliJ IDEA.
  User: hedingwei
  Date: 6/17/15
  Time: 9:54 AM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="am" uri="http://pm.ambimmort.com/app/tags" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap Core CSS -->
    <link href="${ctxStatic}/css/bootstrap.css" rel="stylesheet">

    <!-- DataTables CSS -->
    <link href="${ctxStatic}/css/plugins/dataTables.bootstrap.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${ctxStatic}/css/smartech.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${ctxStatic}/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- Animate CSS -->
    <link href="${ctxStatic}/css/animate.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="${ctxStatic}/js/html5shiv.js"></script>
    <script src="${ctxStatic}/js/respond.min.js"></script>
    <![endif]-->


</head>
<body>

<div id="wrapper">

    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
        <sys:header/>
        <!-- /.navbar-top-links -->

        <sys:sidebar menuId="5100"/>
        <!-- /.navbar-static-side -->
    </nav>

    <div id="page-wrapper">

        <c:if test="${((!isRunning)&&(!isUnRegisteredTask))}">
            <div class="row">
                <div class="col-xs-12">
                    <div class="alert alert-warning">
                        <i class="fa fa-info"></i>
                        <b>该任务当前未执行, 如果需要可以
                            <a  href="${ctx}/f/lttask/start.view.do?taskId=${param.taskId}" >手动触发执行</a>,
                            也可以返回<a  href="${ctx}/f/lttask/list.view.do" class=" addLoading">长时任务管理中心</a>
                        </b>

                    </div>
                </div>

            </div>
        </c:if>

        <c:if test="${((!isRunning)&&(isUnRegisteredTask))}">
            <div class="row">
                <div class="col-md-10">
                    <div class="alert alert-warning">
                        <i class="fa fa-info"></i>
                        <b>该任务当前未执行, 如果需要可以
                            <a  href="${ctx}/f/lttask/start.view.do?taskId=${param.taskId}" >手动触发执行</a>,
                            也可以返回<a  href="${ctx}/f/lttask/list.view.do" class=" addLoading">长时任务管理中心</a>
                        </b>

                    </div>
                </div>

            </div>
        </c:if>

        <%--<c:if test="${!hasHistoryTask}">--%>
        <%--<div class="row">--%>
        <%--<div class="col-sm-12 col-lg-offset-0">--%>
        <%--<div class="alert alert-info alert-dismissable">--%>
        <%--<i class="fa fa-info"></i>--%>
        <%--<b>该任务还没有被执行过, 如果需要可以--%>
        <%--<a  href="${pageContext.request.contextPath}/f/lttask/manager/start.view.do?taskId=${param.taskId}" class="appendBreadcrumb addLoading">手动触发执行</a>,--%>
        <%--也可以返回<a  href="${pageContext.request.contextPath}/f/lttask/manager/list.view.do" class="appendBreadcrumb addLoading">长时任务管理中心</a>--%>
        <%--</b>--%>
        <%--</div>--%>
        <%--</div>--%>

        <%--</div>--%>
        <%--</c:if>--%>

        <c:if test="${isUnRegisteredTask}">
            <div class="row">
                <div class="col-sm-12 col-lg-offset-0">
                    <div class="alert alert-danger alert-dismissable">
                        <i class="fa fa-info"></i>
                        <b>注意：该任务不是一个注册了的合法任务。
                        </b>
                    </div>
                </div>

            </div>
        </c:if>

        <c:if test="${hasHistoryTask&&(param.isUnRegisteredTask==null)}">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h4 class="margin-none">
                                <i class="fa fa-tasks fa-fw"></i> 最近一次执行日志：${task_model.name}
                            </h4>
                            <div class="margin-none text-muted margin-top">
                                <c:if test="${task_model.activator=='system'}">
                                    <p><strong>启动者:</strong> 系统任务调度器 &nbsp;&nbsp;&nbsp;&nbsp; <strong>启动时间:</strong> <am:timestamp-format timestamp="${task_model.startTime}" format="yyyy-MM-dd HH:mm:ss"/></p>

                                </c:if>
                                <c:if test="${task_model.activator!='system'}">
                                    <p><strong>启动人:</strong> ${task_model.activator} &nbsp;&nbsp;&nbsp;&nbsp; <strong>启动时间:</strong> <am:timestamp-format timestamp="${task_model.startTime}" format="yyyy-MM-dd HH:mm:ss"/></p>

                                </c:if>
                            </div>

                        </div>
                        <div class="panel-body">
                            <c:if test="${(task_model.context.subtaskSequence!=null)&&(task_model.context.subtaskSequence.size()!=0)}">
                                <div class="row">

                                    <div class="col-md-12">
                                        <div class="accordion-style1 panel-group">
                                            <h5>分步执行情况详情：</h5>
                                            <c:forEach items="${task_model.context.subtaskModels}" var="subtask" varStatus="step">

                                                <c:if test="${subtask.status=='success'}">

                                                    <div class="panel panel-default">
                                                        <div class="panel-heading">
                                                            <div class="panel-title">
                                                                <a data-toggle="collapse" data-parent="#accordion" href="#collapse${step.index+1}" class="accordion-toggle">
                                                                        ${step.index+1}. ${subtask.name} 执行完成
                                                                </a>
                                                            </div>

                                                        </div>
                                                        <div id="collapse${step.index+1}" class="panel-collapse collapse">
                                                            <div class="panel-body">
                                                                <p>任务描述：${subtask.description}</p>
                                                                <p>任务状态：执行完毕</p>

                                                                <p>任务开始时间：<am:timestamp-format timestamp="${subtask.startTime}" format="yyyy-MM-dd HH:mm:ss"/></p>
                                                                <p>任务结束时间：<am:timestamp-format timestamp="${subtask.stopTime}" format="yyyy-MM-dd HH:mm:ss"/></p>
                                                                <p>任务是否被取消：${subtask.cancelled}</p>
                                                                <p>任务被取消原因：<am:decode-base64 var="${subtask.cancelReason}"/></p>
                                                                <p>任务被谁启动：${subtask.activator}</p>
                                                                <p>任务被谁终止：${subtask.canceller}</p>
                                                                <p>任务执行ID：${subtask.id}</p>
                                                                <p>任务日志：
                                                                <ol>
                                                                    <c:forEach items="${subtask.logs}" var="log">
                                                                        <li>
                                                                            <p><am:decode-base64 var="${log}"/></p>
                                                                        </li>
                                                                    </c:forEach>
                                                                </ol>
                                                                </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </c:if>

                                                <c:if test="${subtask.status=='ready'}">
                                                    <div class="panel panel-default">
                                                        <div class="panel-heading">
                                                            <div class="panel-title">
                                                                <a data-toggle="collapse" data-parent="#accordion" href="#collapse${step.index+1}" class="accordion-toggle">
                                                                        ${step.index+1}. ${subtask.name} 未执行
                                                                </a>
                                                            </div>

                                                        </div>
                                                        <div id="collapse${step.index+1}" class="panel-collapse collapse">
                                                            <div class="panel-body">
                                                                <p>任务描述：${subtask.description}</p>

                                                                <c:if test="${subtask.status=='ready'}">
                                                                    <p>任务状态：未执行</p>
                                                                </c:if>

                                                                <p>任务开始时间：<am:timestamp-format timestamp="${subtask.startTime}" format="yyyy-MM-dd HH:mm:ss"/></p>

                                                                <p>任务结束时间：<am:timestamp-format timestamp="${subtask.stopTime}" format="yyyy-MM-dd HH:mm:ss"/></p>
                                                                <p>任务是否被取消：${subtask.cancelled}</p>
                                                                <p>任务被取消原因：<am:decode-base64 var="${subtask.cancelReason}"/> </p>
                                                                <p>任务被谁启动：${subtask.activator}</p>
                                                                <p>任务被谁终止：${subtask.canceller}</p>
                                                                <p>任务执行ID：${subtask.id}</p>
                                                                <p>任务日志：
                                                                <ol>
                                                                    <c:forEach items="${subtask.logs}" var="log">
                                                                        <li>
                                                                            <p><am:decode-base64 var="${log}"/></p>

                                                                        </li>
                                                                    </c:forEach>
                                                                </ol>
                                                                </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </c:if>
                                                <c:if test="${subtask.status=='cancelled'}">
                                                    <div class="panel panel-default">
                                                        <div class="panel-heading">
                                                            <div class="panel-title">
                                                                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion"  href="#collapse${step.index+1}" >
                                                                        ${step.index+1}. ${subtask.name} 执行失败
                                                                </a>
                                                            </div>

                                                        </div>
                                                        <div id="collapse${step.index+1}" class="panel-collapse collapse">
                                                            <div class="panel-body">
                                                                <p>任务描述：${subtask.description}</p>

                                                                <c:if test="${subtask.status=='cancelled'}">
                                                                    <p>任务状态：执行失败</p>
                                                                </c:if>
                                                                <p>任务开始时间：<am:timestamp-format timestamp="${subtask.startTime}" format="yyyy-MM-dd HH:mm:ss"/></p>

                                                                <p>任务结束时间：<am:timestamp-format timestamp="${subtask.stopTime}" format="yyyy-MM-dd HH:mm:ss"/></p>
                                                                <p>任务是否被取消：${subtask.cancelled}</p>
                                                                <p>任务被取消原因：<am:decode-base64 var="${subtask.cancelReason}"/> </p>
                                                                <p>任务被谁启动：${subtask.activator}</p>
                                                                <p>任务被谁终止：${subtask.canceller}</p>
                                                                <p>任务执行ID：${subtask.id}</p>
                                                                <p>任务日志：
                                                                <ol>
                                                                    <c:forEach items="${subtask.logs}" var="log">
                                                                        <li>
                                                                            <p><am:decode-base64 var="${log}"/></p>

                                                                        </li>
                                                                    </c:forEach>
                                                                </ol>
                                                                </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </c:if>


                                            </c:forEach>
                                        </div>
                                    </div>

                                </div>
                            </c:if>

                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div>
            </div>
        </c:if>

        <div class="text-center margin-top footer">&copy; 2015北京坤腾畅联科技有限公司 版权所有</div>

    </div>

</div>
<!-- jQuery Version 1.11.0 -->
<script src="${ctxStatic}/js/jquery-1.11.0.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="${ctxStatic}/js/bootstrap.min.js"></script>
<script src="${ctxStatic}/js/plugins/layer/layer.js"></script>
<!-- DataTables JavaScript -->
<script src="${ctxStatic}/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="${ctxStatic}/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<!-- Custom Theme JavaScript -->
<script src="${ctxStatic}/js/smartech.js"></script>

<script type="text/javascript">
    /*  function Loading() {
     var cont = '';
     cont += "<div class='loading' id='loading' style='width: 100%; height: 100%; position: absolute;z-index:99999; opacity: 0.5; top: 0px; left: 0px; margin: 0px; padding: 0px; background-color: rgb(255, 255, 255);'>";
     cont += "   <img style='margin-left:50%; margin-top:25%;' src='/nisp3/resources/assets/images/loading.gif'>";
     cont += "</div>";
     $("body").append(cont);
     }
     */
    /* $('.addLoading').click(function(){

     Loading();
     var t=setTimeout("document.getElementById('loading').remove()",3000);

     });*/

</script>


</body>
</html>
